$(() => {
    const user = JSON.parse(sessionStorage.getItem('user'))
    $('#avatarPreview').attr('src', user.avatar)
    $('#nickName').html(user.nickName)

    $.ajax({
        type: 'get',
        url: '/posts/count',
        success(res) {
            $('#articleBox').html(`<strong>${res.postCount}</strong>篇文章（<strong>${res.draftCount}</strong>篇草稿）`)
        }
    })

    $.ajax({
        type: 'get',
        url: '/categories/count',
        success(res) {
            $('#categoryBox').html(`<strong>${res.categoryCount}</strong>个分类`)
        }
    })

    $.ajax({
        type: 'get',
        url: '/comments/count',
        success(res) {
            $('#commentBox').html(`<strong>${res.commentCount}</strong>条评论（<strong>${res.commentCount}</strong>条待审核）`)
        }
    })
})